package com.zpb.admin.controller;

import com.zpb.framework.domain.ApiResult;
import com.zpb.framework.domain.dto.LinkAddDto;
import com.zpb.framework.domain.dto.LinkQueryDto;
import com.zpb.framework.domain.dto.LinkUpdateDto;
import com.zpb.framework.domain.vo.LinkVo;
import com.zpb.framework.domain.vo.PageVo;
import com.zpb.framework.service.LinkService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Description:
 * @Author: zhaopengbo
 * @Date: 2025/9/23
 */
@RestController
@RequestMapping("/content/link")
public class ContentLinkController {
    @Autowired
    private LinkService linkService;
    @GetMapping("/list")
    public ApiResult<PageVo> getLinkList(@RequestParam(defaultValue = "1") Integer pageNum,
                                         @RequestParam(defaultValue = "2") Integer pageSize,
                                         LinkQueryDto queryDto) {
        return linkService.getLinkList(pageNum,pageSize,queryDto);
    }
    @PostMapping
    public ApiResult addLink(@RequestBody LinkAddDto linkAddDto) {
        return linkService.addLink(linkAddDto);
    }
    @GetMapping("/{id}")
    public ApiResult<LinkVo> getLink(@PathVariable Long id) {
        return linkService.getLinkById(id);
    }
    @PutMapping
    public ApiResult updateLink(@RequestBody LinkUpdateDto linkUpdateDto) {
        return linkService.updateLink(linkUpdateDto);
    }
    @DeleteMapping("/{id}")
    public ApiResult deleteLink(@PathVariable Long id) {
        return linkService.deleteLink(id);
    }

}
